﻿<Window x:Class="ForumsBrowser.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:fb="clr-namespace:ForumsBrowser"
    Title="Forums Browser" Height="526" Width="836" x:Name="mainWindow" Loaded="mainWindow_Loaded"
        StateChanged="mainWindow_StateChanged"
       >
    <Window.Resources>
        <ResourceDictionary>
            <fb:ForumView Grid.Row="0" x:Key="forumView" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                                  Background="Black"
                                  Visibility="Visible"  
                                  ThreadSelected="forumView_ThreadSelected" HorizontalContentAlignment="Stretch"
                                  ViewLastPost="forumView_ViewLastPost" Browse="forumView_Browse"/>
            <fb:ThreadViewer x:Key="threadViewer" VerticalAlignment="Stretch" /> 
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="DefaultStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Grid ShowGridLines="False" VerticalAlignment="Stretch">
        <Grid.Resources>
            <BooleanToVisibilityConverter x:Key="BoolVis"/>
            <fb:DoublePercentConverter x:Key="DoublePercentConverter"/>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="1" Name="grid1" ShowGridLines="False" Background="Black" VerticalAlignment="Stretch" >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" x:Name="topPanel"/>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid x:Name="topgridpanel" Height="114" Grid.Row="0">
                <Grid.Triggers>
                    <EventTrigger RoutedEvent="Grid.MouseEnter">
                        <BeginStoryboard Name="tcStoryboard">
                            <Storyboard >
                                <DoubleAnimation Duration="0:0:1" AccelerationRatio="0.8" Storyboard.TargetProperty="Height" 
                                                 To="{Binding ElementName=mainWindow, Path=ActualHeight, Converter={StaticResource DoublePercentConverter}, ConverterParameter=0.8}" />
                            </Storyboard>
                        </BeginStoryboard>
                        
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Grid.MouseLeave">
                        <StopStoryboard BeginStoryboardName="tcStoryboard"/>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Grid.MouseLeave">
                        <BeginStoryboard>
                            <Storyboard x:Name="closeListBox">
                                <DoubleAnimation Duration="0:0:1" DecelerationRatio="0.5" Storyboard.TargetProperty="Height" 
                                                 To="114"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Grid.Triggers>
            </Grid>

            <!--<GridSplitter Grid.Row="2" Height="2" VerticalAlignment="Top" HorizontalAlignment="Stretch"/>-->
            <Grid  Name="bottomPanel" Margin="0,0,0,0" Grid.Row="1" 
                   HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                   >
            </Grid>
        </Grid>
        <StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" Background="Black">
            <StackPanel Orientation="Vertical" VerticalAlignment="Stretch" Background="Black">
                <Expander Name="leftPanel" Margin="0,0,0,15" ExpandDirection="Right" Background="Black" VerticalAlignment="Stretch">
                    <Expander.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="Selected Forums">
                                <TextBlock.LayoutTransform>
                                    <RotateTransform Angle="90"/>
                                </TextBlock.LayoutTransform>
                            </TextBlock>
                        </DataTemplate>
                    </Expander.HeaderTemplate>
                </Expander>
                <Expander Name="allForumsExpander" Margin="0,0,0,15" ExpandDirection="Right" Background="Black" VerticalAlignment="Stretch">
                    <Expander.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="All Forums">
                            <TextBlock.LayoutTransform>
                                <RotateTransform Angle="90"/>
                            </TextBlock.LayoutTransform>
                            </TextBlock>
                        </DataTemplate>
                    </Expander.HeaderTemplate>
                </Expander>
                <Expander Name="userSettingsExpander" Margin="0,0,0,15" ExpandDirection="Right" Background="Black" VerticalAlignment="Stretch">
                    <Expander.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="Settings">
                            <TextBlock.LayoutTransform>
                                <RotateTransform Angle="90"/>
                            </TextBlock.LayoutTransform>
                            </TextBlock>
                        </DataTemplate>
                    </Expander.HeaderTemplate>
                </Expander>
            </StackPanel>
            <fb:SelectedForumsView x:Name="selectedForums" Visibility="{Binding ElementName=leftPanel, Path=IsExpanded, Converter={StaticResource BoolVis} }"  ViewSelected="ViewSelectedForums" />
            <fb:AvailableForumsView x:Name="availableForums" 
                                    Visibility="{Binding ElementName=allForumsExpander, Path=IsExpanded, Converter={StaticResource BoolVis} }"  
                                    ForumSelected="ForumSelected" ForumSubscribed="ForumSubscribed" 
                                    ForumUnsubscribed="ForumUnsubscribed"  VerticalAlignment="Stretch"
                                    Width="300" FinishedLoading="availableForums_FinishedLoading" />
            <fb:UserSettings x:Name="userSettings" MaxWidth="250"  Visibility="{Binding ElementName=userSettingsExpander, Path=IsExpanded, Converter={StaticResource BoolVis} }" Done="userSettings_Done" Cancel="userSettings_Cancel"/>
        </StackPanel>
    </Grid>
</Window>
